#!-*- encoding:utf8 -*-
from django.db import models
from newosmp.monitor.models import Monitor
from newosmp.host.models import Product
from django.contrib.auth.models import User
from newosmp.define import CH_STAT
from newosmp.group.models import Group

class Report(models.Model):
    '''user extra profile table'''
    name = models.CharField(max_length=50)
    tpl = models.CharField(max_length=10)  #报表类型 http...
    statistics = models.CharField(max_length=2, choices = CH_STAT) #统计方式
    pid = models.ForeignKey(Product)    #对应产品线
    freq = models.IntegerField()    #发送保镖频率
    status = models.BooleanField()  #是否订阅
    mid = models.CharField(max_length=1000)    #数据源主机列表
    filed = models.CharField(max_length=20) #数据字段
    table = models.CharField(max_length=100) #数据结果表

    def __unicode__(self):
        return "%s" % self.name

    def __str__(self):
        return "%s" % self.name

#class ReportSource(models.Model):
#    rid = models.ForeignKey(Report)
#    filed = models.CharField(max_length=20)
#    mid = models.ForeignKey(Monitor)

class ReportReceive(models.Model):
    rid = models.ForeignKey(Report)
    type = models.BooleanField()    #接受人类型
    uid = models.ForeignKey(User, blank=True)
    gid = models.ForeignKey(Group, blank=True)
    #sendtime = models.CharField(max_length=20)

    def __unicode__(self):
        return "RRid: " + "%s" % self.id

    def __str__(self):
        return "RRid: "+ "%s" % self.id
